home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / tatriv12.lha / rexx / TATRIVIA.TRANS
Text File  |  1995-07-18  |  10KB  |  412 lines

  1. /* $VER: TA-Trivia v1.2 (7/16/95) for TransAmiga by John Kratz
  2.    Fidonet 1:2608/22.0, Internet jkratz@erc.cat.syr.edu
  3. */
  4. /*   
  5.    This program may be freely distributed by and among sysops using any BBS
  6.    software, so long as those persons have never denied anyone use of any
  7.    software they have written or modified because of BBS software type.
  8. */
  9.  
  10. options results
  11. signal on syntax
  12. signal on error
  13. signal on ioerr
  14.  
  15. oneright=0        /* Number of minutes to add for 1 right answers  */
  16. tworight=0        /* Number of minutes to add for 2 right answers  */
  17. threeright=0        /* Number of minutes to add for 3 right answers  */
  18. fourright=5        /* Number of minutes to add for 4 right answers  */
  19. fiveright=5        /* Number of minutes to add for 5 right answers  */
  20. sixright=5        /* Number of minutes to add for 6 right answers  */
  21. sevenright=5        /* Number of minutes to add for 7 right answers  */
  22. eightright=10        /* Number of minutes to add for 8 right answers  */
  23. nineright=10        /* Number of minutes to add for 9 right answers  */
  24. tenright=20        /* Number of minutes to add for 10 right answers */
  25.  
  26. total=278        /* total number of question files available      */
  27.  
  28. ui=userinfo;tr=transmit;gc=getchar;ss=sendstring;si=systeminfo
  29.  
  30. ui a;handle=result
  31. ui a;name=result
  32.  
  33. ui o;access=result
  34. si m;timeallowed=(result-3)
  35.  
  36. bbsidentify 'name';bbsname=result
  37. test=bbsname;namecount=length(test)
  38. spacenum=59-namecount
  39. spaces=" ";spaces1=" "
  40. do i=1 to spacenum
  41.     spaces=spaces||spaces1
  42. end
  43. ver="TA Trivia v1.2"
  44. bbsidentify 'sysop';sysopname=result
  45. bbsidentify bbs ; bbsversion=result
  46. bbstype=left(bbsversion,4)
  47. Highscores="BBS:Extras/TATRIVIA/Highscores.txt"
  48. c=0
  49. setnodelocation "Playing the Trivia game!"
  50. sysoplog name 'played the Trivia Game!'
  51. if bbstype="Tran" then do
  52.     bbs="T"
  53.     Games='BBS:Extras/'
  54.     USERINFO x ; ansi = RESULT
  55.     CSI   = '1b'x||'['
  56.      if ansi='ON' then do
  57.      OFF    = CSI'0;37m'
  58.        RED    = CSI'31m'
  59.        GREEN  = CSI'32m'
  60.        YELLOW   = CSI'33m'
  61.        BLUE   = CSI'34m'
  62.        PURPLE = CSI'35m'
  63.        CYAN   = CSI'36m'
  64.        WHITE  = CSI'37m'
  65.        yellowback = CSI'43m'
  66.        greenback = CSI'42m'
  67.        blueback = CSI'44m'
  68.  END
  69.  ELSE DO
  70.    OFF    = ''
  71.    RED    = ''
  72.    GREEN  = ''
  73.    YELLOWOW = ''
  74.    BLUE   = ''
  75.    PURPLE = ''
  76.    CYAN   = ''
  77.    WHITE  = ''
  78.  END    
  79. default = ""
  80. end
  81. path=games"TaTrivia/"
  82. upath=path"users/"
  83. qpath=path"Questions/"
  84. quest="Questions"
  85. high=games path"HighScores.txt"
  86. index=1
  87. check=1
  88. used.1=0
  89.  
  90. START:
  91. INST:
  92.     ss green
  93.     sendfile path"Inst"bbs
  94.         address command 'WAIT 3 secs'
  95.  
  96. TITLESCREEN:
  97.     cls
  98.     sendstring OFF
  99.     sendfile path"title"bbs
  100.     bufferflush
  101.         tr ''
  102.  
  103. MAIN:
  104. tr center('[V]iew High Scores',100) 
  105. tr center('[P]lay TA Trivia',99) 
  106. tr center('[Q]uit',89)
  107. ss '                  Your Choice? ' ; gc ;ans=upper(ans) ; call GCCHECK
  108. if ans='P' then do
  109.      cls 
  110.      call STARTOVER
  111.      end
  112. if ans='V' then do
  113.      cls
  114.      call SHOWHIGHS
  115.      continue
  116.      call TITLESCREEN
  117.      end
  118. if ans='Q' then signal QUIT
  119. if ans='RESULT' then cls ; signal TITLESCREEN
  120.  
  121. STARTOVER:
  122.     num=1;count=1
  123.     score=0
  124.     timenumb=0
  125.     listnum=random(1,total,66)
  126.  
  127. GETQUESTIONS:
  128.     listnum=random(1,total,time('s'))
  129.     do i=1 to check
  130.         if used.i=listnum then signal GETQUESTIONS
  131.     end
  132.     used.index=listnum
  133.     check=index
  134.     index=index+1
  135.     if index=276 then do
  136.         do i=1 to check
  137.             used.i=0
  138.         end
  139.         index=1
  140.         check=1
  141.     end
  142.     if open('file',qpath||quest||listnum,'R') then do
  143.         do until EOF('file')
  144.             quest.num=readln('file')
  145.                 do i=1 to 4
  146.                 quest.num.i=readln('file')
  147.                 end
  148.             num=num+1
  149.         end
  150.             call close('file')
  151.     end
  152.     else do
  153.         tr "There has been a problem loading the question file"
  154.         exit 10
  155.     end
  156. SHOW:
  157.     cls
  158.     if count=num-1 then signal SHUTDOWN
  159.     tr ""
  160.     tr ""
  161.     ss BLUE bbsname"'s "RED"Trivia Quiz"spaces"" 
  162.     tr ""
  163.         tr yellowback Green ver "by John Kratz of Amiga Time BBS!     "OFF
  164.     tr " "
  165.     if access = 255 then do
  166.         ss green "Question File number:" yellow listnum" "
  167.     end
  168.     tr green "Question number:" yellow count
  169.     tr " "
  170.         tr CYAN quest.count Yellow
  171.         tr ""
  172.             do i=1 to 4
  173.                 parse var quest.count.i isans 2 answer
  174.                 if isans="!" then theans=i
  175.                 if isans~="-" then transmit i"" answer
  176.             end
  177.     bufferflush
  178.     tr ''
  179.     tr Red"You have "score" right."
  180.         tr '' 
  181.     ss Purple"Your Choice -> ";gc;
  182. ASKIT:
  183.     guess=upper(result)
  184.     tr cyan guess
  185.     if guess="1" then signal CONTINUE
  186.     if guess="2" then signal CONTINUE
  187.     if guess="3" & if isans~="-" then signal CONTINUE
  188.     if guess="4" & if isans~="-" then signal CONTINUE
  189.     if guess="Q" then signal SHUTDOWN
  190.         if guess="RESULT" then SIGNAL MAIN2
  191.     if guess="q" then do
  192.         guess=upper(guess)
  193.                   signal SHUTDOWN
  194.     end
  195.         if guess~= "1" or guess ~= "2" or guess ~= "3" or guess ~= "4" or guess ~= "RESULT" then SIGNAL MAIN2
  196.     if guess="###PANIC" then signal exit 10
  197.     if guess="###panic" then signal exit 10
  198.     signal ASKIT
  199. MAIN2:
  200. Query Purple"FYour Choice -> "
  201. signal ASKIT
  202.  
  203. CONTINUE:
  204.     if guess=theans then do
  205.         score=score+1
  206.         tr CYAN"  Correct."
  207.     end
  208.     else tr RED"  Sorry, that's wrong."
  209.         address command 'WAIT 1 secs'
  210.     count=count+1
  211.     if count>num then do
  212.         if guess=theans then do
  213.             tr CYAN"Correct."
  214.         end
  215.         else tr RED"Sorry, that's wrong."
  216.                 address command 'WAIT 1 secs'
  217.         signal SHUTDOWN
  218.     end
  219.     signal SHOW
  220.  
  221. GCCHECK:
  222. ans=result
  223. if ans ='###PANIC' then do ; bufferflush ; exit 10 ; end
  224. return
  225.  
  226. SHOWHIGHS:
  227. call READHIGH
  228. call SHOWFIVE
  229. return
  230.  
  231. CHECKHI:
  232. call READHIGH
  233. x=0 ; gp=c ; if gp<=0 then signal L288
  234.  
  235. L276:
  236. x=x+1 ; if x>10 then signal L288
  237. z=10 ; if zp.x.2=0 then signal L283
  238. if gp<zp.x.2 then signal L276
  239.  
  240. L283:
  241. z1=z-1
  242. do y=1 to 3
  243.    zp.z.y=zp.z1.y
  244. end y
  245. z=z-1 ; if z~<x then signal L283
  246. zp.x.1=handle ; zp.x.2=gp ;zp.x.3=date() 
  247. tr "Congratulations! You Are One Of The Top 10 Players!"
  248. call open(f1,HIGHSCORES,'w')
  249. do x=1 to 10
  250.    do y=1 to 3
  251.       call writeln(f1,zp.x.y)
  252.    end y
  253. end x ; call close(f1)
  254. if gs=0 then cls ; call SHOWHIGHS
  255. call WAIT
  256. return
  257.  
  258. L288:
  259. tr "Sorry, You Did Not Make It In The Top Ten. Try Again Next Time."
  260. address command 'WAIT 2 secs'
  261. SIGNAL ANOTHER
  262. return
  263.  
  264. READHIGH:
  265. if ~exists(HighScores) then do
  266.    call open(f1,HighScores,'w')
  267.    do x=1 to 10
  268.    call writeln(f1,"Nobody Yet!") ; call writeln(f1,"0") ; call writeln(f1,"None Yet!!!")
  269.    end x ; call close(f1)
  270. end
  271.  
  272. call open(f1,HighScores,'r')
  273. do x=1 to 10
  274.    do y=1 to 3
  275.       zp.x.y=readln(f1)
  276.    end y
  277. end x ; call close(f1)
  278. return
  279.  
  280. SHOWFIVE:
  281. tr ' ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»'
  282. tr ' º               TA Trivia High Scores!               º'
  283. tr ' º        Current Top Ten TA Trivia Champs:Cº'
  284. tr ' ºCº'
  285. tr ' º     NAMECTOTAL SCORE!CDATECº'
  286. tr ' ºCº'
  287. do x=1 to 10
  288. tr ' º'right('<'||x||'>',4)'  '||left(zp.x.1'                   ',20)''right(zp.x.2,2)' C'right(zp.x.3,11)'  º'
  289. end x
  290. tr ' ºCº'
  291. tr ' ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ'
  292. return
  293.  
  294.  
  295. SHUTDOWN:
  296. give=0
  297. si m ; ontime=result
  298. si q ; maxtime=result
  299. if score=0 then SIGNAL L288
  300. if count>9 & score>0 then do
  301.     if score=1 then do
  302.     tr blue'Although you made it into the TOP TEN, you must score 4 or more correct'
  303.     tr 'to win extra online time.' 
  304.     address command 'Wait 2 secs'
  305.     SIGNAL CHECKHI
  306.     end
  307.     if score=2 then do
  308.     tr blue'Although you made it into the TOP TEN, you must score 4 or more correct'
  309.     tr 'to win extra online time.' 
  310.     address command 'Wait 2 secs'
  311.     SIGNAL CHECKHI
  312.     end
  313.     if score=3 then do
  314.     tr blue'Although you made it into the TOP TEN, you must score 4 or more correct'
  315.     tr 'to win extra online time.' 
  316.     address command 'Wait 2 secs'
  317.     SIGNAL CHECKHI
  318.     end
  319.     if score=4 then do
  320.         newtime = ontime + fourright
  321.         settime newtime
  322.         timenumb=fourright
  323.                 c=4
  324.     end
  325.     if score=5 then do
  326.                 newtime = ontime + fiveright
  327.         settime newtime
  328.         timenumb=fiveright
  329.                 c=5
  330.     end
  331.     if score=6 then do
  332.         newtime = ontime + sixright
  333.         settime newtime
  334.         timenumb=sixright
  335.                 c=6
  336.     end
  337.     if score=7 then do
  338.         newtime = ontime + sevenright
  339.         settime newtime
  340.         timenumb=sevenright
  341.                 c=7
  342.     end
  343.     if score=8 then do
  344.         newtime = ontime + eightright
  345.         settime newtime
  346.         timenumb=eightright
  347.                 c=8
  348.     end
  349.     if score=9 then do
  350.         newtime = ontime + nineright
  351.         settime newtime
  352.         timenumb=nineright
  353.                 c=9
  354.     end
  355.     if score=10 then do
  356.         newtime = ontime + tenright
  357.         settime newtime
  358.         timenumb=tenright
  359.                 c=10
  360.     end
  361. end
  362. if count >9 then tr green"You have been given "timenumb" extra minutes online for your "score" correct answers."
  363. if timenumb>0 then do
  364.      si m ; ontime=result
  365.      si q ; maxtime=result
  366.      setnewtime = ontime + timenumb
  367.      tr 'Your OLD time remaining is:' ontime 'minutes'
  368.      tr 'Your New time remaining is:' setnewtime 'minutes'
  369.      if setnewtime>maxtime then do 
  370.         setnewtime=maxtime 
  371.         tr 'Sorry, you can only have 'maxtime 'minutes/day total'
  372.         end
  373.      continue
  374.      settime setnewtime
  375. end
  376.      give=1
  377.         SIGNAL CHECKHI
  378.     if give=0 then ss     
  379. ANOTHER:
  380.     tr''
  381.     ss WHITE"Would you like to try another quiz? "cyan"("green"y"cyan"/"red"N"cyan") "green;gc;again=upper(result)
  382.     if again="Y" then do
  383.         tr "Yes"
  384.         signal STARTOVER
  385.     end
  386.         tr ""
  387.         tr green"Returning you to "bbsname"."
  388.         address command 'Wait 2 sec'
  389.         cls
  390.     exit 10
  391.  
  392. WAIT:
  393. bufferflush ; continue ;cls ; return
  394.  
  395. QUIT:
  396. cls
  397. Tr 'Thank you' name 'for playing TA Trivia!'
  398. bufferflush ; exit 10
  399.  
  400. ERROR:
  401. IOERR:
  402. SYNTAX:
  403.     transmit "Error in "ver".  Line:  "SIGL
  404.     transmit "Error:  "RCALL errortext(RC)
  405.     transmit "Please notify "sysopname"!"
  406.     transmit "Returning to "BBSname"..."
  407.     LOGENTRY "Error in "ver".  Line:  "SIGL
  408.     LOGENTRY "Error:  "RCALL errortext(RC)
  409.     BUFFERFLUSH
  410.     END
  411.     EXIT 10
  412.